<!-- 评分时统计信息 -->
<template>
  <van-row>
    <van-nav-bar
      left-text="返回"
      :title="assessType === $vo.AssessType.CORP + '' ? '科室评分情况统计' : '部门评分情况统计'"
      @click-left="$emit('onCancel')"/>
    <van-cell center label-width="85%" class="card-grade-sketch" v-for="(statItem) in statList" :key="statItem.dept" >
      <template #icon>
        <van-image round width="40px" height="40px" fit="contain" src='none'>
<!--          <template #error><span>{{statItem.dept.substr(0, 4)}}</span></template>-->
          <template #error><span>{{statItem.department_path.substring(statItem.department_path.lastIndexOf('/') + 1).substr(0, 4)}}</span></template>
        </van-image>
      </template>
      <!-- 使用 title 插槽来自定义标题 -->
      <template #default>
        <van-row class="card-label">
          <van-row class="van-ellipsis">
            {{statItem.department_path}}
          </van-row>
          <van-row gutter="2">
            <van-col span="12">
              完成评分：{{statItem.problem_num}}
            </van-col>
            <van-col span="12">
              扣分总计：{{Math.round(statItem.score * 100) / 100}}
            </van-col>
          </van-row>
        </van-row>
      </template>
    </van-cell>
  </van-row>
</template>
<script>
import { getSubDeptStat } from '@/api/assess'
export default {
  name: 'PageGradeStat',
  props: ['assessType'],
  data () {
    return {
      statList: []
    }
  },
  mounted () {
    let condition = {}
    condition.userid = this.$store.state.authInfo.user.userid
    condition.department_path = this.$route.query.bmmc != undefined ? this.$route.query.bmmc : this.$store.state.authInfo.currentDept.department_path
    condition.problem_type = this.assessType
    getSubDeptStat(condition).then(res => {
      let { data } = res
      if (data[this.$response.CODE] === this.$response.SUCCESS) {
        this.statList = data[this.$response.DATA]
      } else {
        this.$toast.fail('获取数据失败：' + data[this.$response.MESSAGE])
      }
    }, errFunc => {
      this.$notify('服务调用失败：' + errFunc.toString())
      console.log(errFunc.toString())
    })
  }
}
</script>
<style lang="less" scoped>
  .card-grade-sketch{
    .van-tag{
      width: 80px;
      justify-content: center;
    }
    .van-image{
      text-align: center;
      /deep/ .van-image__error{
        background-color: #6f9dd8;
      }
      span{
        line-height: 14px;
        padding: 0px 5px;
        font-size: 12px;
        color: white;
      }
    }
    .card-label {
      .van-row:first-child{
        font-weight: 600;
      }
      line-height: 18px;
      padding: 0px 0px 0px 5px;
      font-size: 12px;
    }
  }
  .van-cell{
    padding: 10px 16px 10px 5px;
  }
</style>
